 package client.inventory;

 import client.MapleBuffStat;
 import client.MapleCharacter;
 import com.alibaba.druid.pool.DruidPooledConnection;
 import java.io.Serializable;
 import java.lang.ref.WeakReference;
 import java.sql.PreparedStatement;
 import java.sql.SQLException;
 import tools.MaplePacketCreator;
 import tools.Randomizer;


 public class MapleMount
   implements Serializable
 {
   private static final long serialVersionUID = 9179541993413738569L;
   private int itemid;
   private int skillid;
/*  20 */   private long lastFatigue = 0L; private int exp; private byte fatigue; private byte level;
   private transient boolean changed = false;
   private transient WeakReference<MapleCharacter> owner;

   public MapleMount() {}

   public MapleMount(MapleCharacter owner, int id, int skillid, byte fatigue, byte level, int exp) {
/*  27 */     this.itemid = id;
/*  28 */     this.skillid = skillid;
/*  29 */     this.fatigue = fatigue;
/*  30 */     this.level = level;
/*  31 */     this.exp = exp;
/*  32 */     this.owner = new WeakReference<>(owner);
   }

   public void saveMount(DruidPooledConnection con, int charid) throws SQLException {
/*  36 */     if (!this.changed) {
       return;
     }
/*  39 */     PreparedStatement ps = con.prepareStatement("UPDATE mountdata SET `Level` = ?, `Exp` = ?, `Fatigue` = ? WHERE characterid = ?");
/*  40 */     ps.setByte(1, this.level);
/*  41 */     ps.setInt(2, this.exp);
/*  42 */     ps.setByte(3, this.fatigue);
/*  43 */     ps.setInt(4, charid);
/*  44 */     ps.executeUpdate();
/*  45 */     ps.close();
   }

   public int getItemId() {
/*  49 */     return this.itemid;
   }

   public void setItemId(int c) {
/*  53 */     this.changed = true;
/*  54 */     this.itemid = c;
   }

   public int getSkillId() {
/*  58 */     return this.skillid;
   }

   public byte getFatigue() {
/*  62 */     return this.fatigue;
   }

   public void setFatigue(byte amount) {
/*  66 */     this.changed = true;
/*  67 */     this.fatigue = (byte)(this.fatigue + amount);
/*  68 */     if (this.fatigue < 0) {
/*  69 */       this.fatigue = 0;
     }
   }

   public int getExp() {
/*  74 */     return this.exp;
   }

   public void setExp(int c) {
/*  78 */     this.changed = true;
/*  79 */     this.exp = c;
   }

   public byte getLevel() {
/*  83 */     return this.level;
   }

   public void setLevel(byte c) {
/*  87 */     this.changed = true;
/*  88 */     this.level = c;
   }

   public void increaseFatigue() {
/*  92 */     this.changed = true;
/*  93 */     this.fatigue = (byte)(this.fatigue + 1);
/*  94 */     if (this.fatigue > 100 && this.owner.get() != null) {
/*  95 */       ((MapleCharacter)this.owner.get()).cancelEffectFromBuffStat(MapleBuffStat.骑兽技能);
     }
/*  97 */     update();
   }

   public boolean canTire(long now) {
/* 101 */     return (this.lastFatigue > 0L && this.lastFatigue + 30000L < now);
   }

   public void startSchedule() {
/* 105 */     this.lastFatigue = System.currentTimeMillis();
   }

   public void cancelSchedule() {
/* 109 */     this.lastFatigue = 0L;
   }

   public void increaseExp() {
     int e;
/* 114 */     if (this.level >= 1 && this.level <= 7) {
/* 115 */       e = Randomizer.nextInt(10) + 15;
/* 116 */     } else if (this.level >= 8 && this.level <= 15) {
/* 117 */       e = Randomizer.nextInt(13) + 7;
/* 118 */     } else if (this.level >= 16 && this.level <= 24) {
/* 119 */       e = Randomizer.nextInt(23) + 9;
     } else {
/* 121 */       e = Randomizer.nextInt(28) + 12;
     }
/* 123 */     setExp(this.exp + e);
   }

   public void update() {
/* 127 */     MapleCharacter chr = this.owner.get();
/* 128 */     if (chr != null)
     {
/* 130 */       chr.getMap().broadcastMessage(MaplePacketCreator.updateMount(chr, false));
     }
   }
 }


/* Location:              C:\PGX\Server.jar!\client\inventory\MapleMount.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */